<?php

class User extends AppModel {

	var $name = 'Users'; 
    
    var $displayField = "username"; 
    
    var $belongsTo = array('Group');
    var $actsAs = array('Acl' => array('type' => 'requester'));
    



     /* function bindNode($user) {
  //  return array('model' => 'SystemRole', 'foreign_key' => $user['User']['system_role_id']);
    }     */


  

    var $hasAndBelongsToMany = array(
        'Company' =>
            array('className'            => 'Company')
        ); 
    /*  
    var $hasAndBelongsToMany = array(
        'Company' =>
            array('className'            => 'Company',
                 'joinTable'              => 'companies_users',
                 'foreignKey'             => 'user_id',
                 'associationForeignKey'  => 'company_id',
                'with'                   => '',
                'conditions'             => '',
                'order'                  => '',
                'limit'                  => '',
                'unique'                 => true,
                'finderQuery'            => '',
                'deleteQuery'            => '',
                'fields'                 => 'descripcion', 
                'insertQuery'            => ''
            )
        ); */    
        
        
    function parentNode() {
        if (!$this->id && empty($this->data)) {
            return null;
        }
        if (isset($this->data['User']['group_id'])) {
        $groupId = $this->data['User']['group_id'];
        } else {
            $groupId = $this->field('group_id');
        }
        if (!$groupId) {
        return null;
        } else {
            return array('Group' => array('id' => $groupId));
        }
    }        

    
}

?>